GBML manual / Drawing

sprite_see_through

Marks everything this object draws as see-through, or takes the mark off, so a look from screen_blend decides how much of it shows on each row: a ghost that fades away toward its feet. on is true to mark it and false to take the mark off. With no blend look on and no dark room, a marked object looks just the way it did.

Works differently on Game Boy - The Game Boy marks the sprite as see-through; as on the Game Boy Advance a mark alone changes nothing, the level comes from a sprite effect, and a marked sprite is drawn on some frames only, so it flickers.

Works differently on Game Boy Color - The Game Boy Color marks the sprite as see-through; as on the Game Boy Advance a mark alone changes nothing, the level comes from a sprite effect, and a marked sprite is drawn on some frames only, so it flickers.

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

sprite_see_through(on)

Arguments

NameType
onbool

Returns

Nothing.

Description

Marks everything this object draws as see-through, or takes the mark off again. A marked object is drawn so that you can see what is behind it, and screen_blend decides how much of it shows on each row. It is how a ghost fades away toward its feet, how a shadow lets the floor through, or how a sign dissolves.

A real capture, two pictures of the same pine forest at dusk with a striped lighthouse on the left and a yellow slab with the word BOO on the right, while a BLEND_FADE_DOWN look is on - in the first both are solid, because they are not marked; in the second both are marked see-through, so each is solid at its top and fades into the forest toward its bottomA real capture, two pictures of the same pine forest at dusk with a striped lighthouse on the left and a yellow slab with the word BOO on the right, while a BLEND_FADE_DOWN look is on - in the first both are solid, because they are not marked; in the second both are marked see-through, so each is solid at its top and fades into the forest toward its bottom
A real capture, two pictures of the same pine forest at dusk with a striped lighthouse on the left and a yellow slab with the word BOO on the right, while a BLENDFADEDOWN look is on - in the first both are solid, because they are not marked; in the second both are marked see-through, so each is solid at its top and fades into the forest toward its bottom

A blend look is on in both pictures. Left: nothing is marked, so the lighthouse and the slab stay solid. Right: both are marked, so the look reaches them. The lighthouse is drawn by the engine for the object; the slab and its word are drawn by an object's Draw event. Real pictures from a Game Boy Advance ROM.

You give it one thing:

It belongs to the object that calls it, so there is no handle to keep: write sprite_see_through(true) in the object's own event and it is that object that is marked.

On its own it changes nothing you can see

A marked object looks exactly the way it did until a blend look is on. The mark only says "this one may be see-through". It is screen_blend that decides how much of it shows, row by row. So the order does not matter: mark first or start the look first. The picture changes when both are there.

Everything the object draws

The mark covers everything the object draws:

Other objects are not touched, and neither is anything a different object drew with a call that names this one.

What shows

A blend look decides how much of a see-through thing shows on each row, and the console has just one pair of see-through numbers for the whole screen. So a marked object, a marked background, a particle effect set to blend and the tiles of a room that says they are see-through all follow the same look. In a dark room, those numbers start from the room's own darkness (see screen_blend): a marked object in a dark room shows only as much of itself as the room's darkness says.

A picture is see-through against whatever is behind it, so there has to be something behind it. A marked object that stands in front of nothing is blended with the room's own background color.

What it costs

No row-by-row slot and no matrix. A project that never calls sprite_see_through or sprite_blocky keeps none of the code. A project that does keeps a small table for up to 32 objects marked at once (about 1 KB of the console's big, slow memory), and once a frame it writes the flag on the pictures of every marked object. Measured on a real ROM, with 32 objects each drawing a rectangle: the first marked object costs about 2 hundredths of a frame (that is the pass over everything the game has drawn), 8 marked objects about 4 hundredths, and all 32 about 8 hundredths.

Marking a 33rd object, or calling it where there is no object (a room's creation code, a script), does not just do nothing: a development build stops with a message that says what is wrong, and a release build marks nothing.

Turning it off

Call sprite_see_through(false); and the flag comes off the object's pictures at once. When the object is destroyed or its room ends, its mark ends by itself.

Example

sprite_see_through(true);
screen_blend(BLEND_FADE_DOWN, 3, 0);

A ghost that is solid at the top of the screen and fades away toward the bottom. Call it in the object's Create event.

if (btn_pressed(BTN_A)) {
    sprite_see_through(true);
}

if (btn_pressed(BTN_B)) {
    sprite_see_through(false);
}

Pressing A marks the object so a blend look reaches it; pressing B takes the mark off. Pressing A again changes nothing, because the object is already marked.

draw_rect_fill(x - 32, y - 36, 64, 72, COLOR_YELLOW);
draw_text(x, y, "BOO");

An object with a Draw event that draws a slab and a word. If the object is marked, both are see-through together.

On the GBA

Costs no row-by-row slot and no matrix. It marks everything the object draws: the picture the engine draws for it by itself, and whatever its Draw event draws (sprites, text, rectangles). It keeps a small record for the object, up to 32 objects at a time, in 640 bytes of the console’s big, slow memory (EWRAM) that a project which never calls it does not have, and once a frame it sets the console’s see-through flag on each of the object’s pictures; a picture the engine lets go of and makes again gets its flag again the same frame. The console blends a marked picture with whatever is behind it, using the weights screen_blend sets row by row: the same one pair a dark room’s shroud, a marked background and a blending particle effect use. With no blend look and no dark room those weights show the picture in full, so nothing changes; in a dark room they are the room’s darkness, so a marked object shows that much. The mark stays until you turn it off or the object is destroyed. Call it from the object’s own event, once: the Create event is the place. An event the object has from a parent cannot find its pool unless the code names the child, and a call that finds no object (a room’s creation code, a script) is refused. Marking a 33rd object is refused too: a development build stops with a message, a release build marks nothing. A picture the sprite window uses (a light’s hole) is never made see-through.

See also: screen_blendsprite_blockybackground_see_throughsprite_warpdraw_spritedraw_text